package com.zjitc.chapter08.advice;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
@Aspect
public class AnnoAdvice {
    @Pointcut("execution(* com.zjitc.chapter08.dao.impl.UserDaoImpl.*(..))")
    public void pointcut() { }
    @Before("pointcut()")
    public void before(JoinPoint point) {
        System.out.println("前置通知");
        System.out.println("目标类:" + point.getTarget());
        System.out.println("目标方法:" + point.getSignature().getName());
    }
    @AfterReturning("pointcut()")
    public void afterReturning(JoinPoint point) {
        System.out.println("后置通知");
        System.out.println("目标类:" + point.getTarget());
        System.out.println("目标方法:" + point.getSignature().getName());
    }
    @AfterThrowing("pointcut()")
    public void afterThrowing() {
        System.out.println("异常通知");

    }
    @After("pointcut()")
    public void after() {
        System.out.println("最终通知");

    }
    @Around("pointcut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        System.out.println("这是环绕通知之前");
        Object obj = point.proceed();
        System.out.println("这是环绕通知之后");
        return obj;
    }
}
